package org.chen.tomcat;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import java.io.IOException;

/**
 * @author Chen
 * @since 2023/6/9 15:55
 */
public class ResponseServletOutPutSteam extends ServletOutputStream {

    /**
     * 响应体
     */
    private final byte[] body = new byte[1024];

    private int pos;

    @Override
    public boolean isReady() {
        return false;
    }

    @Override
    public void setWriteListener(WriteListener writeListener) {

    }

    @Override
    public void write(int b) throws IOException {
        body[pos] = (byte) b;
        pos++;
    }

    public byte[] getBody() {
        return body;
    }

    public int getPos() {
        return pos;
    }
}
